home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / edit_qb.zip / ED.BAS < prev    next >
BASIC Source File  |  1991-05-23  |  4KB  |  118 lines

  1. '==========================================================================
  2. ' Updated 5/21/91
  3. '
  4. ' Edit window routine using BIOS video routines.  
  5.  'Give the routine an existing string to edit  and it edits it.  
  6. ' Don't give an existing string, and a new string is returned.  
  7. ' The Filter$ is used to select the permissible values that
  8. ' can be returned.  If you want all keystrokes to be returned, except
  9. ' those with an ASCII value of less than 32, then make Filter$ a null
  10. ' string.  Also ignores all extended keys (other than Shift-Tab). Invalid
  11. ' keys trigger a beep.
  12. '
  13. 'Inputs:
  14. '    Row% = Row on screen for start of edit box. Range not checked
  15. '    Col% = Col on screen for edit box.
  16. '       Length% = Lenth of row in number of columns, max allowed is 
  17. '       80 characters.
  18. '       Attr% = color of edit box (Background Color * 16 + Foreground Color)
  19. '             This corresponds to the actual CRT format, blinking is allowed.
  20. '       Inputt$ = original input string, not checked for invalid characters
  21. '       Filter$ = The string used to filter out bad keystrokes and only
  22. '             allow the keystrokes setforth in the Filter$
  23. '       Exitkey% = is keystroke used to exit routine.  Only keys recognized are
  24. '            Enter, ESC, TAB and Shift-TAB
  25. '
  26. 'Following editing keys are recognized:
  27. '       Home = move cursor to far left of string
  28. '       End = move cursor to far right of string
  29. '       Ins = toggles the insert mode cursor.  Default is Ins on w/ a big
  30. '           cursor (opposite of QB.EXE, because QB.EXE got it backwards).
  31. '       Left arrow = move cursor left, if at left margin beep
  32. '       Right arrow = move cursor right, if at right margin beep
  33. '       Backspace = move cursor left, erasing character to left of cursor.  if
  34. '             at left margin beep
  35. '       Del = erase character under cursor, don't move cursor, but move 
  36. '       portion of string from the cursor right, left one character
  37. '
  38. 'Output:
  39. '       A string with a LEN <= Length, with trailing spaces removed.  The
  40. '       output string is a normal variable length string.
  41. 'Not sure why you would want to do it, but with a proper Filter$, could
  42. 'accept input using ALT-SHIFT numeric keypad to enter graphics characters.
  43. '
  44. 'This demo is not copywrited, however the MASM source code is copyrighted.
  45. '==========================================================================
  46. DEFINT A-Z
  47. DECLARE FUNCTION EDITOR$ (BYVAL ROW%, BYVAL COL%, BYVAL Length%, BYVAL Attr%, Inputt$, Filter$, ExitKey%)
  48. 'tells whether video is using a color or mono port so can guess at display 
  49. 'type and proper color choices.
  50. DECLARE FUNCTION INCOLOR% ()
  51.  
  52. CONST TextFilter$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz"
  53. CONST PhoneFilter$ = "1234567890 ()-"
  54.  
  55. CHR34$ = CHR$(34)
  56.  
  57. IF INCOLOR% THEN
  58.      COLOR 7, 1
  59.      Attr = &H3E     'Yellow on Blue
  60. ELSE
  61.      COLOR 7, 0
  62.      Attr = &H70     'Inverse video
  63. END IF
  64.  
  65. CLS
  66. ROW = 2: COL = 20: Length = 40
  67. Inputt$ = "This is a test!"
  68. Temp$ = EDITOR$(ROW%, COL%, Length%, Attr%, Inputt$, TextFilter$, ExitKey%)
  69.  
  70. LOCATE 4, 3
  71. PRINT "I got "; CHR34$; Temp$; CHR34$; "."
  72. LOCATE 5, 3
  73. PRINT "Length of result string was"; STR$(LEN(Temp$)); "."
  74. LOCATE 6, 3
  75. PRINT "The Exit key was ";
  76. GOSUB NameKey
  77. PRINT T$; "."
  78.  
  79. DO       'pause until user strikes a key
  80. LOOP UNTIL LEN(INKEY$)
  81. 'Above is much faster than
  82. 'do
  83. 'loop until inkey$ <> ""
  84.  
  85. CLS
  86. ROW = 2: COL = 20: Length = 40
  87. Inputt$ = "(412) 561-0950"
  88. Temp$ = EDITOR$(ROW%, COL%, Length%, Attr%, Inputt$, PhoneFilter$, ExitKey%)
  89.  
  90. LOCATE 4, 3
  91. PRINT "I got "; CHR34$; Temp$; CHR34$; "."
  92. LOCATE 5, 3
  93. PRINT "Length of result string was"; STR$(LEN(Temp$)); "."
  94. LOCATE 6, 3
  95. PRINT "The Exit key was ";
  96. GOSUB NameKey
  97. PRINT T$; "."
  98.  
  99. END
  100.  
  101. 'A gosub is used to save space in the .EXE file.  Gosub's are fairly fast
  102. 'becuase they use a near call rather than a far call.
  103. NameKey:
  104.      SELECT CASE ExitKey%
  105.           CASE 13
  106.                T$ = "Enter"
  107.           CASE 9
  108.                T$ = "Tab"
  109.           CASE 15
  110.                T$ = "Shift-Tab"
  111.           CASE 27
  112.                T$ = "Escape"
  113.           CASE ELSE
  114.                T$ = "Invalid"
  115.      END SELECT
  116.      RETURN
  117.  
  118.